import React from 'react';
import { Routes, Route } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import Navbar from './components/layout/Navbar';
import Footer from './components/layout/Footer';
import Home from './pages/Home';
import Login from './pages/auth/Login';
import Register from './pages/auth/Register';
import Dashboard from './pages/dashboard/Dashboard';
import UserManagement from './pages/dashboard/UserManagement';
import ActivityManagement from './pages/dashboard/ActivityManagement';
import GroupManagement from './pages/dashboard/GroupManagement';
import UserProfile from './pages/user/UserProfile';
import UserActivities from './pages/user/UserActivities';
import UserGroups from './pages/user/UserGroups';
import ProtectedRoute from './components/auth/ProtectedRoute';
import AdminRoute from './components/auth/AdminRoute';
import './App.css';

function App() {
  return (
    <div className="flex flex-col min-h-screen">
      <main className="flex-grow">
        <Navbar />
        <Routes>
          {/* 公共路由 */}
          <Route path="/" element={<Home />} />
          <Route path="/auth/login" element={<Login />} />
          <Route path="/auth/register" element={<Register />} />
          
          {/* 管理员路由 */}
          <Route path="/dashboard" element={
            <AdminRoute>
              <Dashboard />
            </AdminRoute>
          } />
          <Route path="/dashboard/users" element={
            <AdminRoute>
              <UserManagement />
            </AdminRoute>
          } />
          <Route path="/dashboard/activities" element={
            <AdminRoute>
              <ActivityManagement />
            </AdminRoute>
          } />
          <Route path="/dashboard/groups" element={
            <AdminRoute>
              <GroupManagement />
            </AdminRoute>
          } />
          
          {/* 用户路由 */}
          <Route path="/user/profile" element={
            <ProtectedRoute>
              <UserProfile />
            </ProtectedRoute>
          } />
          <Route path="/user/activities" element={
            <ProtectedRoute>
              <UserActivities />
            </ProtectedRoute>
          } />
          <Route path="/user/groups" element={
            <ProtectedRoute>
              <UserGroups />
            </ProtectedRoute>
          } />
        </Routes>
        <Footer />
      </main>
      <ToastContainer 
        position="top-right"
        autoClose={3000}
        hideProgressBar={false}
        newestOnTop={false}
        closeOnClick
        rtl={false}
        pauseOnFocusLoss
        draggable
        pauseOnHover
        theme="light"
      />
    </div>
  );
}

export default App;